package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Awards.ApplicationAwardType;
import com.ruoyi.system.domain.Awards.EvaluationCriteria;
import com.ruoyi.system.service.IApplicationAwardTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 三月
 * 奖金发放类型
 */
@RestController
@RequestMapping("/system/awardType")
public class ApplicationAwardTypeController extends BaseController {
    @Autowired
    private IApplicationAwardTypeService applicationAwardTypeService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ApplicationAwardType applicationAwardType)
    {
        startPage();
        List<ApplicationAwardType> list = applicationAwardTypeService.selectApplicationAwardTypeList(applicationAwardType);
        return getDataTable(list);
    }

    @GetMapping("/studentList")
    public TableDataInfo studentList()
    {
        startPage();
        ApplicationAwardType applicationAwardType=new ApplicationAwardType();
        applicationAwardType.setNowTime(DateUtils.getNowDate());
        List<ApplicationAwardType> list = applicationAwardTypeService.selectApplicationAwardTypeList(applicationAwardType);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplicationAwardType applicationAwardType)
    {
        List<ApplicationAwardType> list = applicationAwardTypeService.selectApplicationAwardTypeList(applicationAwardType);
        ExcelUtil<ApplicationAwardType> util = new ExcelUtil<ApplicationAwardType>(ApplicationAwardType.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{applicationAwardTypeId}")
    public AjaxResult getInfo(@PathVariable("applicationAwardTypeId") Long applicationAwardTypeId)
    {
        return success(applicationAwardTypeService.selectApplicationAwardTypeByApplicationAwardTypeId(applicationAwardTypeId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ApplicationAwardType applicationAwardType)
    {
        return toAjax(applicationAwardTypeService.insertApplicationAwardType(applicationAwardType));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ApplicationAwardType applicationAwardType)
    {
        return toAjax(applicationAwardTypeService.updateApplicationAwardType(applicationAwardType));
    }

    /**
     * 删除【请填写功能名称】
     */
    @DeleteMapping("/{applicationAwardTypeIds}")
    public AjaxResult remove(@PathVariable Long[] applicationAwardTypeIds)
    {
        return toAjax(applicationAwardTypeService.deleteApplicationAwardTypeByApplicationAwardTypeIds(applicationAwardTypeIds));
    }

    /**
     *
     * 以下是评定标准表的操作
     * */

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/evaluationCriteria/list")
    public TableDataInfo listEvaluationCriteria(EvaluationCriteria evaluationCriteria)
    {
        startPage();
        List<EvaluationCriteria> list = applicationAwardTypeService.selectEvaluationCriteriaList(evaluationCriteria);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/evaluationCriteria/export")
    public void exportEvaluationCriteria(HttpServletResponse response, EvaluationCriteria evaluationCriteria)
    {
        List<EvaluationCriteria> list = applicationAwardTypeService.selectEvaluationCriteriaList(evaluationCriteria);
        ExcelUtil<EvaluationCriteria> util = new ExcelUtil<EvaluationCriteria>(EvaluationCriteria.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/evaluationCriteria/{criteriaId}")
    public AjaxResult getInfoEvaluationCriteria(@PathVariable("criteriaId") Long criteriaId)
    {
        return success(applicationAwardTypeService.selectEvaluationCriteriaByCriteriaId(criteriaId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping("/evaluationCriteria/add")
    public AjaxResult addEvaluationCriteria(@RequestBody EvaluationCriteria evaluationCriteria)
    {
        return toAjax(applicationAwardTypeService.insertEvaluationCriteria(evaluationCriteria));
    }

    /**
     * 修改【请填写功能名称】
     */

    @PostMapping("/evaluationCriteria/edit")
    public AjaxResult editEvaluationCriteria(@RequestBody EvaluationCriteria evaluationCriteria)
    {
        return toAjax(applicationAwardTypeService.updateEvaluationCriteria(evaluationCriteria));
    }

    /**
     * 删除【请填写功能名称】
     */

    @DeleteMapping("/evaluationCriteria/{criteriaIds}")
    public AjaxResult removeEvaluationCriteria(@PathVariable Long[] criteriaIds)
    {
        return toAjax(applicationAwardTypeService.deleteEvaluationCriteriaByCriteriaIds(criteriaIds));
    }
}
